﻿/// Copyright © 2013 Microsoft Corporation. 
/// This project is released under the Microsoft Public License (MS-PL)
///
namespace DataMorph.Common.Contracts
{
    using System;

    public class TagData
    {
        private const int TicksLength = 18;

        private long ticks;

        public string TagId { get; set; }

        public long Ticks
        {
            get
            {
                return this.ticks;
            }

            set
            {
                this.ticks = (value / TimeSpan.TicksPerMinute) * TimeSpan.TicksPerMinute;
            }
        }

        public string Value { get; set; }

        public int Length
        {
            get
            {
                return this.TagId.Length + TicksLength + this.Value.Length + 3;
            }
        }

        public override string ToString()
        {
            return string.Format("{0},{1},{2}", this.TagId, this.Ticks, this.Value);
        }
    }
}